package com.yzzrjy.controller.mainservlet.update;

import com.yzzrjy.Service.UserService;
import com.yzzrjy.util.ResponseUtils;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet(name = "UpdateFaceImageServlet", value = "/updateFaceImage")
public class UpdateFaceImageServlet extends HttpServlet {
    private UserService userService = new UserService();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String uid = request.getParameter("uid");
        String token = request.getParameter("token");
        String imageName = request.getParameter("imageName");
        if(uid == null || token == null || imageName == null){
            ResponseUtils.parameterError(response);
            return;
        }
        try {
            String urls = userService.updateFace(uid, imageName);
            ResponseUtils.success(response, urls);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
